package org.young.common.aop.aspect.impl;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.young.common.aop.aspect.MQProductAspect;

/**
 * Created by young on 16/10/1.
 */
@Aspect
@Component
public class MQProductAspectImpl implements MQProductAspect{

    // 定义一个方法  2016年10月01日22:59:32
    @Pointcut(value = "execution ( * org.young.common.service.*.* (..))")
    public void pointcutMethod(){}

    // 在方法之前执行
    @Before(value = "pointcutMethod()")
    public void beforeMethod(){
        System.out.println("beforeMethod");
    }

    @Around(value = "pointcutMethod()")
    public Object aroundMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        System.out.println("aroundMethod begin");
        Object object = proceedingJoinPoint.proceed();
        System.out.println("aroundMethod end");
        return object;
    }

    @AfterReturning(value = "pointcutMethod()")
    public void afterRetunrningMethod(){
        System.out.println("afterRetunrningMethod ");
    }

    @AfterThrowing(value = "pointcutMethod()")
    public void afterThrowingMethod(){
        System.out.println("afterThrowingMethod ");
    }



    @After(value = "pointcutMethod()")
    public void afterMethod(){
        System.out.println("afterMethod");
    }
}
